package cn.bugDance.test.domain.strategy;

import cn.bugDance.domain.strategy.model.entity.RuleTreeEntity;
import cn.bugDance.domain.strategy.model.entity.RuleTreeFactorEntity;
import cn.bugDance.domain.strategy.service.rule.tree.engine.IRuleEngine;
import cn.bugDance.domain.strategy.service.rule.tree.factory.RuleTreeFactory;
import com.alibaba.fastjson.JSON;
import lombok.extern.slf4j.Slf4j;
import org.junit.Test;
import org.junit.jupiter.api.TestTemplate;
import org.junit.runner.RunWith;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.junit4.SpringRunner;

import javax.annotation.Resource;
import java.util.ArrayList;
import java.util.List;

@SpringBootTest
@RunWith(SpringRunner.class)
@Slf4j
public class RuleEngineTest {

    @Resource
    private IRuleEngine ruleEngine;

    @Test
    public void test_armory(){
        RuleTreeEntity ruleTreeEntity = ruleEngine.armory(100001L);
        log.info("结果为: {}", JSON.toJSONString(ruleTreeEntity));
    }

    @Test
    public void test_process(){
        List<String> ruleModels = new ArrayList<>();
        RuleTreeEntity ruleTreeEntity = ruleEngine.armory(100001L);
        RuleTreeFactorEntity ruleTreeFactorEntity = new RuleTreeFactorEntity();
        ruleTreeFactorEntity.setAwardId(100);
        ruleTreeFactorEntity.setStrategyId(100001L);
        ruleTreeFactorEntity.setRuleModels(ruleModels);
        RuleTreeFactory.RuleTreeActionEntity ruleTreeActionEntity = ruleEngine.process(ruleTreeEntity, ruleTreeFactorEntity);

        log.info("结果为: {}", JSON.toJSONString(ruleTreeActionEntity));
    }
}
